﻿<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<!-- head start -->
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>AFC设备维修系统</title>
		<style>
		#organizesTree {
			margin-top: 10px;
			border: 1px solid #617775;
			background: #f0f6e4;
			min-width: 180px;
			max-height: 400px;
			overflow-y: scroll;
			overflow-x: auto;
		}
		</style>
		<link type="text/css" rel="stylesheet"
			href="<%=request.getContextPath()%>/css/common.css" />
		<link type="text/css" rel="stylesheet"
			href="<%=request.getContextPath()%>/css/tag.css" />
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/jquery-1.7.2.js"></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/My97DatePicker/WdatePicker.js">
		</script>	
		<link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/css/zTreeStyle/zTreeStyle.css" />	
		<link type="text/css" href="<%=request.getContextPath()%>/js/jquery-ui-1.8.21.custom/css/smoothness/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.ztree.core-3.1.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.ztree.excheck-3.1.min.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.21.custom/js/jquery-ui-1.8.21.custom.min.js">
		</script>
		<script type="text/javascript">
			$(function () {
	            // chkAll全选事件
	            $("#allselect").bind("click", function () {
	                $("[name = selectUnit]:checkbox").attr("checked", this.checked);
	            });
	            //selectNav('nav4');
	        });
			function pageSub(currentPage) {
					 var reg=/^\d*?$/;
					 var total =${page.totalPages};
					 if(reg.test(currentPage)){
					 	if(currentPage > total){
					 		$("#currentPage").val(total);
					 	}else{
					 		$("#currentPage").val(currentPage);
					 	}
					 	
						document.forms[0].action="resStateOccupyList.action?mediumStatus=3";
						document.forms[0].submit();
					}else{
						  alert("请输入数字!"); 
					}
		       }	
			function doSubmit(url,mediumStatus){
				var myReg = /^[^@\/\'\\\"#$%_&\^\*<>]+$/;  
				var inputKey = $.trim(document.getElementById("keyname").value);
				if (inputKey != null && inputKey != '' && !myReg.test(inputKey)) {
		                    alert('关键字不能含有特殊字符,请重新输入!')
					}
				else
				{
					document.forms[0].action=url+"?mediumStatus="+mediumStatus;
					document.forms[0].submit();
				}	
		    }  	  	 
			function setAll(url,status){
				var chkName="selectUnit";
				var len = document.getElementById("myForm").elements.length;
				var checkedCount=0;
				for (var i=0;i<len;i++){
					var e = document.getElementById("myForm").elements[i];
					if ((e.type=='checkbox') && (e.name==chkName) &&(e.checked))
						checkedCount++;
				}
				if (checkedCount<=0){
					alert('请至少选择一条记录！');
				}else{
						document.forms[0].action=url+"?mediumStatus="+status+"&oldMediumStatus="+3;
						document.forms[0].submit();
				}
			} 
			function reset2()
			{
				$('#timeres').val($('#defulttime').val());
				$('#media').val('0');
				$('#project').val('0');
				$('#city').val($("#defultcity").val());
				$('#key').val('0');
				$('#keyname').val('');
				$('#orgID').val('');
				document.getElementById("showOrganize").value="--部门科室--";
			} 	    	
    </script>
    <style>
			#queryTab{
				height:32px;
				font-size:14px;
			}
			#queryTab ul li {
				height:32px;
				width:142px;
				line-height:32px;
				text-align:center;
				font-size:14px;
				font-weight:bold;
				
				float:left;
				padding:0px;
				margin:0px;
				border:0;
			}
			#queryTab ul li a{ color:#000000; display:block; line-height:32px;}
			#queryTab .focus{
				background:url("<%=request.getContextPath()%>/images/statetab_select.jpg") no-repeat ;
				color:#FFFFFF;
				
			}
			#queryTab .onfocus{ 
				background:url("<%=request.getContextPath()%>/images/statetab_select.jpg") no-repeat; 
				color:#FFFFFF;
			}	
			.no_select_li_hover{
			    background:url("<%=request.getContextPath()%>/images/statetab_unselect.jpg") no-repeat ;
				color:#000000;
			}	

     </style>
</head>

	<body>
		

		<!-- 顶部start -->
		<jsp:include page="../common/top.jsp"></jsp:include>
		<!-- 顶部end -->


		<!-- 顶部start -->
		<div id="main">
			<div class="body">
				<!-- 导航菜单 -->
				<jsp:include page="../common/nav.jsp"></jsp:include>
				<!-- 主体 -->
<div class="main_body">
  <s:form method="post" id="myForm" name="searchform">
    <input type="hidden" name="currentPage" id="currentPage" />
	 <div style=" width:100%; margin-bottom:8px">
	<jsp:include page="/jsp/resState/header.jsp"></jsp:include>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input name="button" type="button" class="btn-title" value="搜索" onclick="doSubmit('resStateOccupyList.action','3');"/> 
			  &nbsp;&nbsp;&nbsp;
			  <input name="button" type="button" class="btn-title" value="重置" onclick="reset2();"/> 
			  </td>
			</tr>
		</table>
	</div>
	<div id="queryTab" style="width:"100%">
          <ul>
			  <li class="no_select_li_hover" ><a href="#" onclick="doSubmit('resStatePreviewList.action','1');" > 预占(${preCount}/${sumCount})</a></li>
              <li class="no_select_li_hover"><a href="#"  onclick="doSubmit('resStatePeddingList.action','2');" >呈批中(${peddingCount}/${sumCount})</a></li> 
			  <li class="focus" ><a href="#" style="color:#FFFFFF;" onclick="doSubmit('resStateOccupyList.action','3');" > 占用(${occupyCount}/${sumCount})</a></li> 
			  <li class="no_select_li_hover" ><a href="#" onclick="doSubmit('resStateFinishPutList.action','4');" > 完成投放(${finishPutCount}/${sumCount})</a></li> 
			  <li class="no_select_li_hover" ><a href="#" onclick="doSubmit('resStateFinishSettlementList.action','5');" >完成结算(${finishSetCount}/${sumCount})</a></li> 
			  <li class="no_select_li_hover" ><a href="#" onclick="doSubmit('resStateSuspendedList.action','6');" > 已中止(${suspendedCount}/${sumCount})</a></li>
	      </ul>
	</div>
	<hr size='5px'  style=" margin:0; width=100%;" />
	<div id="list_div"  >
		<table class="table_list"  style="width:100%;">
			<tr class="bg">
				<th><input id="allselect" type="checkbox" /> </th>
				<th>占用状态</th>
				<th>刊例名称</th>
				<th>项目名称</th>
				<th>媒体类型</th>
				<th>归属地市</th>
				<th>投放位置</th>
				<th>资源类型</th>
				<th>使用额度</th>
				<th>项目类型</th>
				<th>部门归属科室</th>
				<th>项目负责人</th>
				<th>排期时间</th>
			</tr>
			<s:iterator value="projectMediums" id="projMedium">
			<tr>
				<td><input type="checkbox" name="selectUnit" value="<s:property value="%{proMedID}"/>"/></td>
				<td>
				    <s:if test="#projMedium.mediumStatus.length()>6">
							<label title="<s:property value="#projMedium.mediumStatus" />">
								<s:property value="#projMedium.mediumStatus.substring(0,6)+'...'" />
							</label>
					</s:if>
					<s:else>
							<s:property value="#projMedium.mediumStatus" />
					</s:else>
				</td>
				<td>
				     <s:if test="#projMedium.medium.mediumName.length()>6">
							<label title="<s:property value="#projMedium.medium.mediumName" />">
								<s:property value="#projMedium.medium.mediumName.substring(0,6)+'...'" />
							</label>
					</s:if>
					<s:else>
							<s:property value="#projMedium.medium.mediumName" />
					</s:else>
				</td>
				<td>
				     <s:if test="#projMedium.project.projectName.length()>9">
							<label title="<s:property value="#projMedium.project.projectName" />">
								<s:property value="#projMedium.project.projectName.substring(0,9)+'...'" />
							</label>
					</s:if>
					<s:else>
							<s:property value="#projMedium.project.projectName" />
					</s:else>
				</td>
				<td>
				     <s:if test="#projMedium.mediasumm.mediaType.length()>6">
							<label title="<s:property value="#projMedium.mediasumm.mediaType" />">
								<s:property value="#projMedium.mediasumm.mediaType.substring(0,6)+'...'" />
							</label>
					</s:if>
					<s:else>
							<s:property value="#projMedium.mediasumm.mediaType" />
					</s:else>
				</td>
				<td>
				     <s:if test="#projMedium.project.city.length()>4">
							<label title="<s:property value="#projMedium.project.city" />">
								<s:property value="#projMedium.project.city.substring(0,4)+'...'" />
							</label>
					</s:if>
					<s:else>
							<s:property value="#projMedium.project.city" />
					</s:else>
				</td>
				<td>
				     <s:if test="#projMedium.medium.mediumPosition.length()>4">
							<label title="<s:property value="#projMedium.medium.mediumPosition" />">
								<s:property value="#projMedium.medium.mediumPosition.substring(0,4)+'...'" />
							</label>
					</s:if>
					<s:else>
							<s:property value="#projMedium.medium.mediumPosition" />
					</s:else>
				</td>
				<td>
				     <s:if test="#projMedium.mediaPrice.mediaResourceType.length()>4">
							<label title="<s:property value="#projMedium.mediaPrice.mediaResourceType" />">
								<s:property value="#projMedium.mediaPrice.mediaResourceType.substring(0,4)+'...'" />
							</label>
					</s:if>
					<s:else>
							<s:property value="#projMedium.mediaPrice.mediaResourceType" />
					</s:else>
				</td>
				<td>
				    <fmt:formatNumber value="${mediumTotalPrice}" type="number" pattern="##0.0#" />
				</td>
				<td>
				     <s:if test="#projMedium.project.projectType.length()>4">
							<label title="<s:property value="#projMedium.project.projectType" />">
								<s:property value="#projMedium.project.projectType.substring(0,4)+'...'" />
							</label>
					</s:if>
					<s:else>
							<s:property value="#projMedium.project.projectType" />
					</s:else>
				</td>
				<td>
				     <s:if test="#projMedium.project.projectSection.length()>4">
							<label title="<s:property value="#projMedium.project.projectSection" />">
								<s:property value="#projMedium.project.projectSection.substring(0,4)+'...'" />
							</label>
					</s:if>
					<s:else>
							<s:property value="#projMedium.project.projectSection" />
					</s:else>
				</td>
				<td>
				     <s:if test="#projMedium.project.projectManager.length()>4">
							<label title="<s:property value="#projMedium.project.projectManager" />">
								<s:property value="#projMedium.project.projectManager.substring(0,4)+'...'" />
							</label>
					</s:if>
					<s:else>
							<s:property value="#projMedium.project.projectManager" />
					</s:else>
				</td>
				<td><s:property value="#projMedium.arrangeTime"/></td>
			</tr>
			</s:iterator>
		</table>
	</div>
	<!-- 分页 -->
	<jsp:include page="/jsp/common/page.jsp"></jsp:include>
	</s:form>
   </div>  
   <div >
		<table width="100%">
			<tr>      
			  <td  style=" height:40px; width: 10%"><input name="button" type="button" class="btn-title" value="    修改为预占      " onclick="setAll('occuSetProjectMediumState.action','1');"/> </td>             
			  <td  style=" height:40px; width: 10%"><input name="button" type="button" class="btn-title" value="  修改为呈批中   " onclick="setAll('occuSetProjectMediumState.action','2');"/> </td>           
			  <td  style=" height:40px; width: 10%"><input name="button" type="button" class="btn-title" value=" 修改为完成投放 "  onclick="setAll('occuSetProjectMediumState.action','4');"/> </td>            
			  <td  style=" height:40px; width: 10%"><input name="button" type="button" class="btn-title" value=" 修改为完成结算 "  onclick="setAll('occuSetProjectMediumState.action','5');"/> </td>             
			  <td  style=" height:40px; width: 10%"><input name="button" type="button" class="btn-title" value=" 修改为中止投放 " onclick="setAll('occuSetProjectMediumState.action','6');"/> </td>  
			  <td  style=" height:40px; width: 10%"><input name="button" type="button" class="btn-title" value=" 返回 " onclick="gotoCastDetail();"/> </td>             
              <td style=" height:40px; width: 40%"></td>
            </tr>
        </table>
	</div>
  </div>
 </div>
<!-- 顶部end -->


			<!-- 底部start -->
			<div id="bottom">
				<div class="body">
					<label>
						版权所有&nbsp;&nbsp;&nbsp;&nbsp;2012东莞移动
					</label>
				</div>
			</div>
			<!-- 底部end -->
			<div id="organizeContent" class="menuContent"
			style="display: none; position: absolute;">
			<ul id="organizesTree" class="ztree" style="margin-top: 0;"></ul>
		</div>
			<script type="text/javascript">
	
	//获取后台数据显示组织架构
	var organizes =${flag};
	
	//组织架构初始化
	var organizeSetting = {
		view : {
			dblClickExpand : false
		},
		data : {
			simpleData : {
				enable : true
			}
		},
		callback : {
			beforeClick : beforeClick,
			onClick : organizeOnClick
		}
	};
		//页面加载
	$(function() {
		//设置组织架构弹出框
		$.fn.zTree.init($("#organizesTree"), organizeSetting, organizes);
	});

	//点击事件
	function beforeClick(treeId, treeNode) {
		var check = (treeNode && !treeNode.isParent);
		if (!check)
			alert("出现没有选择的！呼呼、、、");
		return check;
	}

	//组织架构点击事件
	function organizeOnClick(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("organizesTree"), nodes = zTree.getSelectedNodes(), v = "";
		nodes.sort(function compare(a, b) {
			return a.id - b.id;
		});
		for ( var i = 0, l = nodes.length; i < l; i++) {
			v += nodes[i].name + ",";
		}
		if (v.length > 0)
			v = v.substring(0, v.length - 1);
		var orgNameObj = $("#showOrganize");
		orgNameObj.attr("value", v);
		//设置隐藏域中组织编号  
		$('#orgID').val(treeNode.id);
		hideMenu('organizeContent');
	}

	//隐藏组织架构
	function hideMenu(divId) {
		$("#" + divId).fadeOut("fast");
		$("body").unbind("mousedown", {
			tempDiv : divId
		}, onBodyDown);
	}

	//组织架构弹出窗
	function showMenu(objId, divId) {
		var cityObj = $("#" + objId);
		var cityOffset = $("#" + objId).position();
		$("#" + divId).css( {
			left : cityOffset.left + "px",
			top : cityOffset.top + cityObj.outerHeight() + "px"
		}).slideDown("fast");
		$("body").bind("mousedown", {
			tempDiv : divId
		}, onBodyDown);
	}
		//鼠标点击别的地方隐藏弹出属性菜单
	function onBodyDown(event) {
		var divId = event.data.tempDiv;
		if (!(event.target.id == "showOrganize" || $(event.target).parents(
				"#" + divId).length > 0)) {
			hideMenu(divId);
		}
	}
		//参数非空验证
	function paramIsNull(paramId){
		var temp = $('#'+paramId).val();
		if(null == temp || temp=='')
		{
			return false;
		}
		else{
			//文本框去左右空格重新赋值
			$('#'+paramId).val($.trim(temp));
			return true;
		}
	} 
	</script>
	</body>
</html>